<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                template="/WEB-INF/facelets/template.xhtml"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:p="http://primefaces.prime.com.tr/ui" 
                
                
                xmlns:f="http://java.sun.com/jsf/core">

    <ui:param name="title" value="View Cart"/>
    <ui:define name="form">
        <h:form>
            <p>
                <h:commandButton value="View Products" action="onViewProducts"/>
                <h:commandButton value="Empty Shopping Cart and View Products" action="#{viewCartControllerBean.emptyCart()}"/>
            </p>
        </h:form>
        
        <h:form>
        <p>
            
        <p:dataTable var="product" value="#{viewCartControllerBean.productsInCart}">
            
            <p:column parser="number" sortBy="#{product.id}">
                <f:facet name="header">
                    <h:outputText value="ID" />
                </f:facet>
                <h:outputText value="#{product.id}" />
            </p:column>
            
            <p:column sortBy="#{product.cat}">
                <f:facet name="header">
                    <h:outputText value="Category" />
                </f:facet>
                <h:outputText value="#{product.cat}" />
            </p:column>
            
            <p:column sortBy="#{product.name}">
                <f:facet name="header">
                    <h:outputText value="Name" />
                </f:facet>
            <h:outputText value="#{product.name}" />
            </p:column>
            
            <p:column parser="number" sortBy="#{product.price}">
                <f:facet name="header">
                    <h:outputText value="Price" />
                </f:facet>
                <h:outputText value="#{product.price}" />
            </p:column>
            
            <p:column>
                <p:commandButton value="Remove" actionListener="#{shoppingCartModelBean.removeProduct(product)}" update="@form" />
            </p:column>

            
        </p:dataTable>
        
        </p>

        <p>The number of items currently in the shopping cart: #{shoppingCartModelBean.getNumberOfProducts()}</p>

        </h:form>
        
        
    </ui:define>
    <ui:param name="h1" value="View Cart"/>

</ui:composition>